/*
 * Powered By [rapid-framework]
 * Web Site: http://www.rapid-framework.org.cn
 * Google Code: http://code.google.com/p/rapid-framework/
 * Since 2008 - 2013
 */

package org.teacup.eightdays.model;

import javax.persistence.*;

import org.hibernate.annotations.GenericGenerator;

import javax.validation.constraints.*;
import org.hibernate.validator.constraints.*;
import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.commons.lang.builder.ToStringBuilder;
import org.apache.commons.lang.builder.ToStringStyle;

import java.util.*;

import javacommon.base.*;
import javacommon.util.*;

import cn.org.rapid_framework.util.*;
import cn.org.rapid_framework.web.util.*;
import cn.org.rapid_framework.page.*;
import cn.org.rapid_framework.page.impl.*;

import org.teacup.eightdays.model.*;
import org.teacup.eightdays.dao.*;
import org.teacup.eightdays.service.*;
import org.teacup.eightdays.vo.query.*;

/**
 * @author Abner email:521yexu2008(a)163.com
 * @version 1.0
 * @since 1.0
 */

@Entity
@Table(name = "orderinfo")
public class Orderinfo extends BaseEntity implements java.io.Serializable{
	private static final long serialVersionUID = 5454155825314635342L;
	
	//alias
	public static final String TABLE_ALIAS = "Orderinfo";
	public static final String ALIAS_ORDER_ID = "ID";
	public static final String ALIAS_MEMBERINFO_ID = "订货人ID";
	public static final String ALIAS_ORDER_NO = "订单号";
	public static final String ALIAS_ORDER_AMOUNT = "订单总价";
	public static final String ALIAS_STATUS = "状态";
	public static final String ALIAS_ORDER_TIME = "预订时间";
	public static final String ALIAS_SCHOOL_ID = "所在学校";
	public static final String ALIAS_MOBILE_NO = "手机号码";
	public static final String ALIAS_NAME = "真实姓名";
	public static final String ALIAS_ADDRESS = "配送地址";
	public static final String ALIAS_REMARK = "备注";
	public static final String ALIAS_BACK_REMARK = "后台备注";
	
	//date formats
	public static final String FORMAT_ORDER_TIME = DATE_FORMAT;
	

	//可以直接使用: @Length(max=50,message="用户名长度不能大于50")显示错误消息
	//columns START
    /**
     * ID       db_column: order_id 
     */ 	
	
	private java.lang.Long orderId;
    /**
     * 订货人ID       db_column: memberinfo_id 
     */ 	
	
	private java.lang.Long memberinfoId;
    /**
     * 订单号       db_column: order_no 
     */ 	
	@Length(max=100)
	private java.lang.String orderNo;
    /**
     * 订单总价       db_column: order_amount 
     */ 	
	
	private java.lang.Float orderAmount;
    /**
     * 状态       db_column: status 
     */ 	
	
	private java.lang.Integer status;
    /**
     * 预订时间       db_column: order_time 
     */ 	
	
	private java.util.Date orderTime;
    /**
     * 所在学校       db_column: school_id 
     */ 	
	
	private java.lang.Long schoolId;
    /**
     * 手机号码       db_column: mobile_no 
     */ 	
	@Length(max=15)
	private java.lang.String mobileNo;
    /**
     * 真实姓名       db_column: name 
     */ 	
	@Length(max=50)
	private java.lang.String name;
    /**
     * 配送地址       db_column: address 
     */ 	
	@Length(max=500)
	private java.lang.String address;
    /**
     * 备注       db_column: remark 
     */ 	
	@Length(max=2147483647)
	private java.lang.String remark;
    /**
     * 后台备注       db_column: back_remark 
     */ 	
	@Length(max=2147483647)
	private java.lang.String backRemark;
	//columns END


	public Orderinfo(){
	}

	public Orderinfo(
		java.lang.Long orderId
	){
		this.orderId = orderId;
	}

	

	public void setOrderId(java.lang.Long value) {
		this.orderId = value;
	}
	
	@Id @GeneratedValue(generator="custom-id")
	@GenericGenerator(name="custom-id", strategy = "increment")
	@Column(name = "order_id", unique = true, nullable = false, insertable = true, updatable = true, length = 19)
	public java.lang.Long getOrderId() {
		return this.orderId;
	}
	
	@Column(name = "memberinfo_id", unique = false, nullable = true, insertable = true, updatable = true, length = 19)
	public java.lang.Long getMemberinfoId() {
		return this.memberinfoId;
	}
	
	public void setMemberinfoId(java.lang.Long value) {
		this.memberinfoId = value;
	}
	
	@Column(name = "order_no", unique = false, nullable = true, insertable = true, updatable = true, length = 100)
	public java.lang.String getOrderNo() {
		return this.orderNo;
	}
	
	public void setOrderNo(java.lang.String value) {
		this.orderNo = value;
	}
	
	@Column(name = "order_amount", unique = false, nullable = true, insertable = true, updatable = true, length = 12)
	public java.lang.Float getOrderAmount() {
		return this.orderAmount;
	}
	
	public void setOrderAmount(java.lang.Float value) {
		this.orderAmount = value;
	}
	
	@Column(name = "status", unique = false, nullable = true, insertable = true, updatable = true, length = 10)
	public java.lang.Integer getStatus() {
		return this.status;
	}
	
	public void setStatus(java.lang.Integer value) {
		this.status = value;
	}
	
	@Transient
	public String getOrderTimeString() {
		return DateConvertUtils.format(getOrderTime(), FORMAT_ORDER_TIME);
	}
	public void setOrderTimeString(String value) {
		setOrderTime(DateConvertUtils.parse(value, FORMAT_ORDER_TIME,java.util.Date.class));
	}
	
	@Column(name = "order_time", unique = false, nullable = true, insertable = true, updatable = true, length = 0)
	public java.util.Date getOrderTime() {
		return this.orderTime;
	}
	
	public void setOrderTime(java.util.Date value) {
		this.orderTime = value;
	}
	
	@Column(name = "school_id", unique = false, nullable = true, insertable = true, updatable = true, length = 19)
	public java.lang.Long getSchoolId() {
		return this.schoolId;
	}
	
	public void setSchoolId(java.lang.Long value) {
		this.schoolId = value;
	}
	
	@Column(name = "mobile_no", unique = false, nullable = true, insertable = true, updatable = true, length = 15)
	public java.lang.String getMobileNo() {
		return this.mobileNo;
	}
	
	public void setMobileNo(java.lang.String value) {
		this.mobileNo = value;
	}
	
	@Column(name = "name", unique = false, nullable = true, insertable = true, updatable = true, length = 50)
	public java.lang.String getName() {
		return this.name;
	}
	
	public void setName(java.lang.String value) {
		this.name = value;
	}
	
	@Column(name = "address", unique = false, nullable = true, insertable = true, updatable = true, length = 500)
	public java.lang.String getAddress() {
		return this.address;
	}
	
	public void setAddress(java.lang.String value) {
		this.address = value;
	}
	
	@Column(name = "remark", unique = false, nullable = true, insertable = true, updatable = true, length = 2147483647)
	public java.lang.String getRemark() {
		return this.remark;
	}
	
	public void setRemark(java.lang.String value) {
		this.remark = value;
	}
	
	@Column(name = "back_remark", unique = false, nullable = true, insertable = true, updatable = true, length = 2147483647)
	public java.lang.String getBackRemark() {
		return this.backRemark;
	}
	
	public void setBackRemark(java.lang.String value) {
		this.backRemark = value;
	}
	
	
	private Set orderItems = new HashSet(0);
	public void setOrderItems(Set<OrderItem> orderItem){
		this.orderItems = orderItem;
	}
	
	@OneToMany(cascade = { CascadeType.MERGE }, fetch = FetchType.LAZY, mappedBy = "orderinfo")
	public Set<OrderItem> getOrderItems() {
		return orderItems;
	}
	
	private School school;
	public void setSchool(School school){
		this.school = school;
	}
	
	@ManyToOne(cascade = {}, fetch = FetchType.LAZY)
	@JoinColumns({
		@JoinColumn(name = "school_id",nullable = false, insertable = false, updatable = false) 
	})
	public School getSchool() {
		return school;
	}
	
	private Memberinfo memberinfo;
	public void setMemberinfo(Memberinfo memberinfo){
		this.memberinfo = memberinfo;
	}
	
	@ManyToOne(cascade = {}, fetch = FetchType.LAZY)
	@JoinColumns({
		@JoinColumn(name = "memberinfo_id",nullable = false, insertable = false, updatable = false) 
	})
	public Memberinfo getMemberinfo() {
		return memberinfo;
	}

	public String toString() {
		return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
			.append("OrderId",getOrderId())
			.append("MemberinfoId",getMemberinfoId())
			.append("OrderNo",getOrderNo())
			.append("OrderAmount",getOrderAmount())
			.append("Status",getStatus())
			.append("OrderTime",getOrderTime())
			.append("SchoolId",getSchoolId())
			.append("MobileNo",getMobileNo())
			.append("Name",getName())
			.append("Address",getAddress())
			.append("Remark",getRemark())
			.append("BackRemark",getBackRemark())
			.toString();
	}
	
	public int hashCode() {
		return new HashCodeBuilder()
			.append(getOrderId())
			.toHashCode();
	}
	
	public boolean equals(Object obj) {
		if(obj instanceof Orderinfo == false) return false;
		if(this == obj) return true;
		Orderinfo other = (Orderinfo)obj;
		return new EqualsBuilder()
			.append(getOrderId(),other.getOrderId())
			.isEquals();
	}
}

